#!/usr/bin/make -f

VERSION?=$(shell cat VERSION)

# force packages to be built with xz compression, as Ubuntu 21.10 and up use
# zstd compression, which is non-standard, and breaks 'dpkg-sig --verify'
override_dh_builddeb:
	dh_builddeb -- -Zxz

override_dh_auto_build:
	cd xray-plugin \
	&& GO111MODULE=on \
		env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VERSION=v$(VERSION) -s -w -buildid=" -o "xray-plugin"

# http://manpages.debian.org/dh_dwz
override_dh_dwz:
	# dh_dwz in debhelper versions less than 13 has issues with files that are missing debug symbols (once we update to debhelper-compat 13+ this can be removed)
	@# https://packages.debian.org/debhelper
	@# https://packages.ubuntu.com/debhelper

override_dh_auto_install:
	install -D -m 0755 xray-plugin/xray-plugin debian/xray-plugin/usr/bin/xray-plugin

override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

%:
	dh $@
